package com.d.ydfactory.handle;

import com.d.ydfactory.constants.ApproveConstant;
import com.d.ydfactory.YdApproveFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 审批控制类
 */
@Service
public class ApproveEventHandle {

    @Autowired
    private Map<String, YdApproveFactory> factoryMap;

    public YdApproveFactory factory(Integer eventType) {
        if (!ApproveConstant.approveTypeRoute.containsKey(eventType)) {
            return null;
        }
        String resolveClass = ApproveConstant.approveTypeRoute.get(eventType);
        if (!factoryMap.containsKey(resolveClass)) {
            return null;
        }
        return factoryMap.get(resolveClass);
    }
}
